package com.skyvin.nreceipts.common.mapper;

import java.util.ArrayList;
import java.util.List;

import org.springframework.data.domain.Page;

import com.skyvin.nreceipts.common.document.ReceiptItem;
import com.skyvin.nreceipts.common.dto.ReceiptItemDTO;

public class ReceiptItemMapper {
	public static ReceiptItemDTO map(ReceiptItem receiptItem) {
		ReceiptItemDTO receiptItemDTO = new ReceiptItemDTO();
		receiptItemDTO.setId(receiptItem.getId());
		receiptItemDTO.setItemId(receiptItem.getItemId());
		receiptItemDTO.setName(receiptItem.getName());
		receiptItemDTO.setPrice(receiptItem.getPrice());
		receiptItemDTO.setUserPID(receiptItem.getUserPID());
		receiptItemDTO.setReceiptItemCategory(receiptItem.getReceiptItemCategory());
		return receiptItemDTO;
	}
	
	public static List<ReceiptItemDTO> map(Page<ReceiptItem> receiptItemDocuments) {
		List<ReceiptItemDTO> receiptItemDTOs = new ArrayList<ReceiptItemDTO>();
		for (ReceiptItem receiptItem : receiptItemDocuments) {
			receiptItemDTOs.add(map(receiptItem));
		}
		return receiptItemDTOs;
	}
}
